package org.htmlparser.http;

import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
import org.htmlparser.util.ParserException;

public class ConnectionManager
{
  private static final char[] BASE64_CHAR_TABLE;
  private static final String[] FOUR_OH_FOUR;
  protected static Hashtable mDefaultRequestProperties = new Hashtable();
  protected static SimpleDateFormat mFormat;
  protected Hashtable mCookieJar;
  protected ConnectionMonitor mMonitor;
  protected String mPassword;
  protected String mProxyHost;
  protected String mProxyPassword;
  protected int mProxyPort;
  protected String mProxyUser;
  protected boolean mRedirectionProcessingEnabled;
  protected Hashtable mRequestProperties;
  protected String mUser;

  static
  {
    mDefaultRequestProperties.put("User-Agent", "HTMLParser/1.6");
    mDefaultRequestProperties.put("Accept-Encoding", "gzip, deflate");
    String[] arrayOfString = new String[10];
    arrayOfString[0] = "The web site you seek cannot be located, but countless more exist";
    arrayOfString[1] = "You step in the stream, but the water has moved on. This page is not here.";
    arrayOfString[2] = "Yesterday the page existed. Today it does not. The internet is like that.";
    arrayOfString[3] = "That page was so big. It might have been very useful. But now it is gone.";
    arrayOfString[4] = "Three things are certain: death, taxes and broken links. Guess which has occured.";
    arrayOfString[5] = "Chaos reigns within. Reflect, repent and enter the correct URL. Order shall return.";
    arrayOfString[6] = "Stay the patient course. Of little worth is your ire. The page is not found.";
    arrayOfString[7] = "A non-existant URL reduces your expensive computer to a simple stone.";
    arrayOfString[8] = "Many people have visited that page. Today, you are not one of the lucky ones.";
    arrayOfString[9] = "Cutting the wind with a knife. Bookmarking a URL. Both are ephemeral.";
    FOUR_OH_FOUR = arrayOfString;
    BASE64_CHAR_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
    mFormat = new SimpleDateFormat("EEE, dd-MMM-yy kk:mm:ss z");
  }

  public ConnectionManager()
  {
    this(getDefaultRequestProperties());
  }

  public ConnectionManager(Hashtable paramHashtable)
  {
    this.mRequestProperties = paramHashtable;
    this.mProxyHost = null;
    this.mProxyPort = 0;
    this.mProxyUser = null;
    this.mProxyPassword = null;
    this.mUser = null;
    this.mPassword = null;
    this.mCookieJar = null;
    this.mMonitor = null;
    this.mRedirectionProcessingEnabled = false;
  }

  public static final String encode(byte[] paramArrayOfByte)
  {
    char[] arrayOfChar;
    int l;
    int i1;
    int i2;
    label139: int i11;
    int i12;
    int i13;
    int i14;
    int i15;
    if ((paramArrayOfByte != null) && (paramArrayOfByte.length != 0))
    {
      int i = paramArrayOfByte.length - 1;
      int j = 1 + i / 3 << 2;
      int k = j + (j - 1) / 76;
      arrayOfChar = new char[k];
      l = 0;
      i1 = 0;
      i2 = 0;
      if (i2 <= i)
      {
        int i4;
        int i5;
        int i3 = i - i2;
        if (i3 > 1)
          i4 = 2;
        while (true)
        {
          i5 = 0;
          int i6 = 0;
          int i7 = 16;
          while (true)
          {
            if (i6 > i4)
              break label139;
            int i17 = paramArrayOfByte[(i2 + i6)];
            if (i17 < 0);
            i5 += ((i17 += 256) << i7);
            int i18 = i7 - 8;
            ++i6;
            i7 = i18;
          }
          i4 = i3;
        }
        int i8 = l + 1;
        arrayOfChar[l] = BASE64_CHAR_TABLE[(0x3F & i5 >>> 18)];
        int i9 = i8 + 1;
        arrayOfChar[i8] = BASE64_CHAR_TABLE[(0x3F & i5 >>> 12)];
        int i10 = i9 + 1;
        if (i3 > 0)
        {
          i11 = BASE64_CHAR_TABLE[(0x3F & i5 >>> 6)];
          arrayOfChar[i9] = i11;
          i12 = i10 + 1;
          if (i3 <= 1)
            break label309;
          i13 = BASE64_CHAR_TABLE[(i5 & 0x3F)];
          arrayOfChar[i10] = i13;
          if (((i12 - i1) % 76 != 0) || (i12 >= k))
            break label334;
          int i16 = i12 + 1;
          arrayOfChar[i12] = '\n';
          i15 = i1 + 1;
          i14 = i16;
        }
      }
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            i2 += 3;
            i1 = i15;
            l = i14;
          }
          i11 = 61;
        }
        label309: i13 = 61;
      }
      String str = new String(arrayOfChar);
      while (true)
      {
        return str;
        str = "";
      }
      label334: i14 = i12;
      i15 = i1;
    }
  }

  public static Hashtable getDefaultRequestProperties()
  {
    return mDefaultRequestProperties;
  }

  public static void setDefaultRequestProperties(Hashtable paramHashtable)
  {
    mDefaultRequestProperties = paramHashtable;
  }

  protected Vector addCookies(Vector paramVector1, String paramString, Vector paramVector2)
  {
    if (paramVector1 != null)
    {
      Date localDate1 = new Date();
      int i = 0;
      if (i < paramVector1.size())
      {
        Cookie localCookie = (Cookie)paramVector1.elementAt(i);
        Date localDate2 = localCookie.getExpiryDate();
        if ((localDate2 != null) && (localDate2.before(localDate1)))
        {
          paramVector1.remove(i);
          --i;
        }
        while (true)
        {
          do
            while (true)
              ++i;
          while (!(paramString.startsWith(localCookie.getPath())));
          if (paramVector2 == null)
            paramVector2 = new Vector();
          paramVector2.addElement(localCookie);
        }
      }
    }
    return paramVector2;
  }

  public void addCookies(URLConnection paramURLConnection)
  {
    Vector localVector1;
    String str1;
    String str2;
    Vector localVector2;
    if (this.mCookieJar != null)
    {
      localVector1 = null;
      URL localURL = paramURLConnection.getURL();
      str1 = localURL.getHost();
      str2 = localURL.getPath();
      if (str2.length() == 0)
        str2 = "/";
      if (str1 != null)
      {
        localVector2 = addCookies((Vector)this.mCookieJar.get(str1), str2, null);
        String str3 = getDomain(str1);
        if (str3 == null)
          break label114;
        localVector1 = addCookies((Vector)this.mCookieJar.get(str3), str2, localVector2);
      }
    }
    while (true)
    {
      if (localVector1 != null)
        paramURLConnection.setRequestProperty("Cookie", generateCookieProperty(localVector1));
      return;
      label114: localVector1 = addCookies((Vector)this.mCookieJar.get("." + str1), str2, localVector2);
    }
  }

  public String fixSpaces(String paramString)
  {
    int i = paramString.indexOf(32);
    if (-1 != i)
    {
      int j = paramString.length();
      StringBuffer localStringBuffer = new StringBuffer(j * 3);
      localStringBuffer.append(paramString.substring(0, i));
      int k = i;
      if (k < j)
      {
        char c = paramString.charAt(k);
        if (c == ' ')
          localStringBuffer.append("%20");
        while (true)
        {
          while (true)
            ++k;
          localStringBuffer.append(c);
        }
      }
      paramString = localStringBuffer.toString();
    }
    return paramString;
  }

  protected String generateCookieProperty(Vector paramVector)
  {
    String str1 = null;
    StringBuffer localStringBuffer = new StringBuffer();
    int i = 0;
    for (int j = 0; j < paramVector.size(); ++j)
      i = Math.max(i, ((Cookie)paramVector.elementAt(j)).getVersion());
    if (i != 0)
    {
      localStringBuffer.append("$Version=\"");
      localStringBuffer.append(i);
      localStringBuffer.append("\"");
    }
    int k = 0;
    if (k < paramVector.size())
    {
      String str2;
      Cookie localCookie = (Cookie)paramVector.elementAt(k);
      if (localStringBuffer.length() != 0)
        localStringBuffer.append("; ");
      localStringBuffer.append(localCookie.getName());
      if (localCookie.getName().equals(""))
        str2 = "";
      while (true)
      {
        while (true)
        {
          localStringBuffer.append(str2);
          if (i != 0)
            localStringBuffer.append("\"");
          localStringBuffer.append(localCookie.getValue());
          if (i != 0)
            localStringBuffer.append("\"");
          if (i != 0)
          {
            if ((localCookie.getPath() != null) && (localCookie.getPath().length() != 0))
            {
              localStringBuffer.append("; $Path=\"");
              localStringBuffer.append(localCookie.getPath());
              localStringBuffer.append("\"");
            }
            if ((localCookie.getDomain() != null) && (localCookie.getDomain().length() != 0))
            {
              localStringBuffer.append("; $Domain=\"");
              localStringBuffer.append(localCookie.getDomain());
              localStringBuffer.append("\"");
            }
          }
          ++k;
        }
        str2 = "=";
      }
    }
    if (localStringBuffer.length() != 0)
      str1 = localStringBuffer.toString();
    return str1;
  }

  public boolean getCookieProcessingEnabled()
  {
    int i;
    if (this.mCookieJar != null)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  protected String getDomain(String paramString)
  {
    String str = null;
    StringTokenizer localStringTokenizer = new StringTokenizer(paramString, ".");
    if (3 <= localStringTokenizer.countTokens())
    {
      int i = paramString.length();
      int j = 0;
      for (int k = 0; (k < i) && (j == 0); ++k)
      {
        char c = paramString.charAt(k);
        if ((!(Character.isDigit(c))) && (c != '.'))
          j = 1;
      }
      if (j != 0)
        str = paramString.substring(localStringTokenizer.nextToken().length());
    }
    return str;
  }

  protected String getLocation(HttpURLConnection paramHttpURLConnection)
  {
    Object localObject = null;
    for (int i = 0; localObject == null; ++i)
    {
      String str1 = paramHttpURLConnection.getHeaderField(i);
      if (str1 == null)
        break;
      String str2 = paramHttpURLConnection.getHeaderFieldKey(i);
      if ((str2 != null) && (str2.equalsIgnoreCase("Location")))
        localObject = str1;
    }
    return localObject;
  }

  public ConnectionMonitor getMonitor()
  {
    return this.mMonitor;
  }

  public String getPassword()
  {
    return this.mPassword;
  }

  public String getProxyHost()
  {
    return this.mProxyHost;
  }

  public String getProxyPassword()
  {
    return this.mProxyPassword;
  }

  public int getProxyPort()
  {
    return this.mProxyPort;
  }

  public String getProxyUser()
  {
    return this.mProxyUser;
  }

  public boolean getRedirectionProcessingEnabled()
  {
    return this.mRedirectionProcessingEnabled;
  }

  public Hashtable getRequestProperties()
  {
    return this.mRequestProperties;
  }

  public String getUser()
  {
    return this.mUser;
  }

  public URLConnection openConnection(String paramString)
    throws ParserException
  {
    Object localObject;
    URLConnection localURLConnection2;
    try
    {
      localURLConnection2 = openConnection(new URL(fixSpaces(paramString)));
      localObject = localURLConnection2;
      return localObject;
    }
    catch (MalformedURLException localMalformedURLException1)
    {
      try
      {
        String str = new File(paramString).getCanonicalPath();
        StringBuffer localStringBuffer = new StringBuffer("file://localhost".length() + str.length());
        localStringBuffer.append("file://localhost");
        if (!(str.startsWith("/")))
          localStringBuffer.append("/");
        localStringBuffer.append(str);
        URLConnection localURLConnection1 = openConnection(new URL(fixSpaces(localStringBuffer.toString())));
        localObject = localURLConnection1;
      }
      catch (MalformedURLException localMalformedURLException2)
      {
        throw new ParserException("Error in opening a connection to " + paramString, localMalformedURLException2);
      }
      catch (IOException localIOException)
      {
        throw new ParserException("Error in opening a connection to " + paramString, localIOException);
      }
    }
  }

  // ERROR //
  public URLConnection openConnection(URL paramURL)
    throws ParserException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aconst_null
    //   3: astore_3
    //   4: aconst_null
    //   5: astore 4
    //   7: aconst_null
    //   8: astore 5
    //   10: aconst_null
    //   11: astore 6
    //   13: iconst_0
    //   14: istore 7
    //   16: iconst_0
    //   17: istore 8
    //   19: aload_0
    //   20: invokevirtual 350	org/htmlparser/http/ConnectionManager:getProxyHost	()Ljava/lang/String;
    //   23: ifnull +108 -> 131
    //   26: aload_0
    //   27: invokevirtual 352	org/htmlparser/http/ConnectionManager:getProxyPort	()I
    //   30: ifeq +101 -> 131
    //   33: invokestatic 358	java/lang/System:getProperties	()Ljava/util/Properties;
    //   36: astore 46
    //   38: aload 46
    //   40: ldc_w 360
    //   43: ldc_w 362
    //   46: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   49: checkcast 49	java/lang/String
    //   52: astore_2
    //   53: aload 46
    //   55: ldc_w 364
    //   58: aload_0
    //   59: invokevirtual 350	org/htmlparser/http/ConnectionManager:getProxyHost	()Ljava/lang/String;
    //   62: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   65: checkcast 49	java/lang/String
    //   68: astore_3
    //   69: aload 46
    //   71: ldc_w 366
    //   74: aload_0
    //   75: invokevirtual 352	org/htmlparser/http/ConnectionManager:getProxyPort	()I
    //   78: invokestatic 370	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   81: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   84: checkcast 49	java/lang/String
    //   87: astore 4
    //   89: aload 46
    //   91: ldc_w 372
    //   94: aload_0
    //   95: invokevirtual 350	org/htmlparser/http/ConnectionManager:getProxyHost	()Ljava/lang/String;
    //   98: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   101: checkcast 49	java/lang/String
    //   104: astore 5
    //   106: aload 46
    //   108: ldc_w 374
    //   111: aload_0
    //   112: invokevirtual 352	org/htmlparser/http/ConnectionManager:getProxyPort	()I
    //   115: invokestatic 370	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   118: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   121: checkcast 49	java/lang/String
    //   124: astore 6
    //   126: aload 46
    //   128: invokestatic 378	java/lang/System:setProperties	(Ljava/util/Properties;)V
    //   131: aload_1
    //   132: invokevirtual 381	java/net/URL:openConnection	()Ljava/net/URLConnection;
    //   135: astore 22
    //   137: aload 22
    //   139: instanceof 298
    //   142: ifeq +600 -> 742
    //   145: aload 22
    //   147: checkcast 298	java/net/HttpURLConnection
    //   150: astore 23
    //   152: aload_0
    //   153: invokevirtual 383	org/htmlparser/http/ConnectionManager:getRedirectionProcessingEnabled	()Z
    //   156: ifeq +9 -> 165
    //   159: aload 23
    //   161: iconst_0
    //   162: invokevirtual 387	java/net/HttpURLConnection:setInstanceFollowRedirects	(Z)V
    //   165: aload_0
    //   166: invokevirtual 389	org/htmlparser/http/ConnectionManager:getRequestProperties	()Ljava/util/Hashtable;
    //   169: astore 42
    //   171: aload 42
    //   173: ifnull +192 -> 365
    //   176: aload 42
    //   178: invokevirtual 393	java/util/Hashtable:keys	()Ljava/util/Enumeration;
    //   181: astore 44
    //   183: aload 44
    //   185: invokeinterface 398 1 0
    //   190: ifeq +175 -> 365
    //   193: aload 44
    //   195: invokeinterface 402 1 0
    //   200: checkcast 49	java/lang/String
    //   203: astore 45
    //   205: aload 22
    //   207: aload 45
    //   209: aload 42
    //   211: aload 45
    //   213: invokevirtual 187	java/util/Hashtable:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   216: checkcast 49	java/lang/String
    //   219: invokevirtual 203	java/net/URLConnection:setRequestProperty	(Ljava/lang/String;Ljava/lang/String;)V
    //   222: goto -39 -> 183
    //   225: astore 9
    //   227: aload_0
    //   228: invokevirtual 350	org/htmlparser/http/ConnectionManager:getProxyHost	()Ljava/lang/String;
    //   231: ifnull +96 -> 327
    //   234: aload_0
    //   235: invokevirtual 352	org/htmlparser/http/ConnectionManager:getProxyPort	()I
    //   238: ifeq +89 -> 327
    //   241: invokestatic 358	java/lang/System:getProperties	()Ljava/util/Properties;
    //   244: astore 11
    //   246: aload_2
    //   247: ifnull +556 -> 803
    //   250: aload 11
    //   252: ldc_w 360
    //   255: aload_2
    //   256: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   259: pop
    //   260: aload_3
    //   261: ifnull +554 -> 815
    //   264: aload 11
    //   266: ldc_w 364
    //   269: aload_3
    //   270: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   273: pop
    //   274: aload 4
    //   276: ifnull +551 -> 827
    //   279: aload 11
    //   281: ldc_w 366
    //   284: aload 4
    //   286: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   289: pop
    //   290: aload 5
    //   292: ifnull +547 -> 839
    //   295: aload 11
    //   297: ldc_w 372
    //   300: aload 5
    //   302: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   305: pop
    //   306: aload 6
    //   308: ifnull +543 -> 851
    //   311: aload 11
    //   313: ldc_w 374
    //   316: aload 6
    //   318: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   321: pop
    //   322: aload 11
    //   324: invokestatic 378	java/lang/System:setProperties	(Ljava/util/Properties;)V
    //   327: aload 9
    //   329: athrow
    //   330: astore 10
    //   332: new 323	ParserException
    //   335: dup
    //   336: new 205	java/lang/StringBuffer
    //   339: dup
    //   340: invokespecial 206	java/lang/StringBuffer:<init>	()V
    //   343: ldc_w 343
    //   346: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   349: aload_1
    //   350: invokevirtual 405	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   353: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   356: invokevirtual 215	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   359: aload 10
    //   361: invokespecial 346	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   364: athrow
    //   365: aload_0
    //   366: invokevirtual 407	org/htmlparser/http/ConnectionManager:getProxyUser	()Ljava/lang/String;
    //   369: ifnull +57 -> 426
    //   372: aload_0
    //   373: invokevirtual 409	org/htmlparser/http/ConnectionManager:getProxyPassword	()Ljava/lang/String;
    //   376: ifnull +50 -> 426
    //   379: aload 22
    //   381: ldc_w 411
    //   384: new 205	java/lang/StringBuffer
    //   387: dup
    //   388: invokespecial 206	java/lang/StringBuffer:<init>	()V
    //   391: aload_0
    //   392: invokevirtual 407	org/htmlparser/http/ConnectionManager:getProxyUser	()Ljava/lang/String;
    //   395: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   398: ldc_w 413
    //   401: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   404: aload_0
    //   405: invokevirtual 409	org/htmlparser/http/ConnectionManager:getProxyPassword	()Ljava/lang/String;
    //   408: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   411: invokevirtual 215	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   414: ldc_w 415
    //   417: invokevirtual 419	java/lang/String:getBytes	(Ljava/lang/String;)[B
    //   420: invokestatic 421	org/htmlparser/http/ConnectionManager:encode	([B)Ljava/lang/String;
    //   423: invokevirtual 203	java/net/URLConnection:setRequestProperty	(Ljava/lang/String;Ljava/lang/String;)V
    //   426: aload_0
    //   427: invokevirtual 423	org/htmlparser/http/ConnectionManager:getUser	()Ljava/lang/String;
    //   430: ifnull +80 -> 510
    //   433: aload_0
    //   434: invokevirtual 425	org/htmlparser/http/ConnectionManager:getPassword	()Ljava/lang/String;
    //   437: ifnull +73 -> 510
    //   440: new 205	java/lang/StringBuffer
    //   443: dup
    //   444: invokespecial 206	java/lang/StringBuffer:<init>	()V
    //   447: aload_0
    //   448: invokevirtual 423	org/htmlparser/http/ConnectionManager:getUser	()Ljava/lang/String;
    //   451: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   454: ldc_w 413
    //   457: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   460: aload_0
    //   461: invokevirtual 425	org/htmlparser/http/ConnectionManager:getPassword	()Ljava/lang/String;
    //   464: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   467: invokevirtual 215	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   470: ldc_w 415
    //   473: invokevirtual 419	java/lang/String:getBytes	(Ljava/lang/String;)[B
    //   476: invokestatic 421	org/htmlparser/http/ConnectionManager:encode	([B)Ljava/lang/String;
    //   479: astore 43
    //   481: aload 22
    //   483: ldc_w 427
    //   486: new 205	java/lang/StringBuffer
    //   489: dup
    //   490: invokespecial 206	java/lang/StringBuffer:<init>	()V
    //   493: ldc_w 429
    //   496: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   499: aload 43
    //   501: invokevirtual 212	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   504: invokevirtual 215	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   507: invokevirtual 203	java/net/URLConnection:setRequestProperty	(Ljava/lang/String;Ljava/lang/String;)V
    //   510: aload_0
    //   511: invokevirtual 431	org/htmlparser/http/ConnectionManager:getCookieProcessingEnabled	()Z
    //   514: ifeq +9 -> 523
    //   517: aload_0
    //   518: aload 22
    //   520: invokevirtual 433	org/htmlparser/http/ConnectionManager:addCookies	(Ljava/net/URLConnection;)V
    //   523: aload_0
    //   524: invokevirtual 435	org/htmlparser/http/ConnectionManager:getMonitor	()Lorg/htmlparser/http/ConnectionMonitor;
    //   527: ifnull +14 -> 541
    //   530: aload_0
    //   531: invokevirtual 435	org/htmlparser/http/ConnectionManager:getMonitor	()Lorg/htmlparser/http/ConnectionMonitor;
    //   534: aload 23
    //   536: invokeinterface 441 2 0
    //   541: aload 22
    //   543: invokevirtual 444	java/net/URLConnection:connect	()V
    //   546: aload 23
    //   548: ifnull +86 -> 634
    //   551: aload_0
    //   552: invokevirtual 435	org/htmlparser/http/ConnectionManager:getMonitor	()Lorg/htmlparser/http/ConnectionMonitor;
    //   555: ifnull +14 -> 569
    //   558: aload_0
    //   559: invokevirtual 435	org/htmlparser/http/ConnectionManager:getMonitor	()Lorg/htmlparser/http/ConnectionMonitor;
    //   562: aload 23
    //   564: invokeinterface 447 2 0
    //   569: aload_0
    //   570: invokevirtual 431	org/htmlparser/http/ConnectionManager:getCookieProcessingEnabled	()Z
    //   573: ifeq +9 -> 582
    //   576: aload_0
    //   577: aload 22
    //   579: invokevirtual 450	org/htmlparser/http/ConnectionManager:parseCookies	(Ljava/net/URLConnection;)V
    //   582: iconst_3
    //   583: aload 23
    //   585: invokevirtual 453	java/net/HttpURLConnection:getResponseCode	()I
    //   588: bipush 100
    //   590: idiv
    //   591: if_icmpne +43 -> 634
    //   594: iload 7
    //   596: bipush 20
    //   598: if_icmpge +36 -> 634
    //   601: aload_0
    //   602: aload 23
    //   604: invokevirtual 455	org/htmlparser/http/ConnectionManager:getLocation	(Ljava/net/HttpURLConnection;)Ljava/lang/String;
    //   607: astore 40
    //   609: aload 40
    //   611: ifnull +23 -> 634
    //   614: new 174	java/net/URL
    //   617: dup
    //   618: aload 40
    //   620: invokespecial 330	java/net/URL:<init>	(Ljava/lang/String;)V
    //   623: astore 41
    //   625: iconst_1
    //   626: istore 8
    //   628: iinc 7 1
    //   631: aload 41
    //   633: astore_1
    //   634: aload_0
    //   635: invokevirtual 350	org/htmlparser/http/ConnectionManager:getProxyHost	()Ljava/lang/String;
    //   638: ifnull +96 -> 734
    //   641: aload_0
    //   642: invokevirtual 352	org/htmlparser/http/ConnectionManager:getProxyPort	()I
    //   645: ifeq +89 -> 734
    //   648: invokestatic 358	java/lang/System:getProperties	()Ljava/util/Properties;
    //   651: astore 29
    //   653: aload_2
    //   654: ifnull +209 -> 863
    //   657: aload 29
    //   659: ldc_w 360
    //   662: aload_2
    //   663: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   666: pop
    //   667: aload_3
    //   668: ifnull +207 -> 875
    //   671: aload 29
    //   673: ldc_w 364
    //   676: aload_3
    //   677: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   680: pop
    //   681: aload 4
    //   683: ifnull +204 -> 887
    //   686: aload 29
    //   688: ldc_w 366
    //   691: aload 4
    //   693: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   696: pop
    //   697: aload 5
    //   699: ifnull +200 -> 899
    //   702: aload 29
    //   704: ldc_w 372
    //   707: aload 5
    //   709: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   712: pop
    //   713: aload 6
    //   715: ifnull +196 -> 911
    //   718: aload 29
    //   720: ldc_w 374
    //   723: aload 6
    //   725: invokevirtual 43	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   728: pop
    //   729: aload 29
    //   731: invokestatic 378	java/lang/System:setProperties	(Ljava/util/Properties;)V
    //   734: iload 8
    //   736: ifne -720 -> 16
    //   739: aload 22
    //   741: areturn
    //   742: aconst_null
    //   743: astore 23
    //   745: goto -204 -> 541
    //   748: astore 26
    //   750: invokestatic 459	java/lang/Math:random	()D
    //   753: getstatic 71	org/htmlparser/http/ConnectionManager:FOUR_OH_FOUR	[Ljava/lang/String;
    //   756: arraylength
    //   757: i2d
    //   758: dmul
    //   759: d2i
    //   760: istore 27
    //   762: new 323	ParserException
    //   765: dup
    //   766: getstatic 71	org/htmlparser/http/ConnectionManager:FOUR_OH_FOUR	[Ljava/lang/String;
    //   769: iload 27
    //   771: aaload
    //   772: aload 26
    //   774: invokespecial 346	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   777: astore 28
    //   779: aload 28
    //   781: athrow
    //   782: astore 24
    //   784: new 323	ParserException
    //   787: dup
    //   788: aload 24
    //   790: invokevirtual 464	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   793: aload 24
    //   795: invokespecial 346	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   798: astore 25
    //   800: aload 25
    //   802: athrow
    //   803: aload 11
    //   805: ldc_w 360
    //   808: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   811: pop
    //   812: goto -552 -> 260
    //   815: aload 11
    //   817: ldc_w 364
    //   820: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   823: pop
    //   824: goto -550 -> 274
    //   827: aload 11
    //   829: ldc_w 366
    //   832: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   835: pop
    //   836: goto -546 -> 290
    //   839: aload 11
    //   841: ldc_w 372
    //   844: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   847: pop
    //   848: goto -542 -> 306
    //   851: aload 11
    //   853: ldc_w 374
    //   856: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   859: pop
    //   860: goto -538 -> 322
    //   863: aload 29
    //   865: ldc_w 360
    //   868: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   871: pop
    //   872: goto -205 -> 667
    //   875: aload 29
    //   877: ldc_w 364
    //   880: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   883: pop
    //   884: goto -203 -> 681
    //   887: aload 29
    //   889: ldc_w 366
    //   892: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   895: pop
    //   896: goto -199 -> 697
    //   899: aload 29
    //   901: ldc_w 372
    //   904: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   907: pop
    //   908: goto -195 -> 713
    //   911: aload 29
    //   913: ldc_w 374
    //   916: invokevirtual 466	java/util/Hashtable:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   919: pop
    //   920: goto -191 -> 729
    //
    // Exception table:
    //   from	to	target	type
    //   19	222	225	finally
    //   365	541	225	finally
    //   541	625	225	finally
    //   750	803	225	finally
    //   227	330	330	java/io/IOException
    //   634	734	330	java/io/IOException
    //   803	920	330	java/io/IOException
    //   541	625	748	java/net/UnknownHostException
    //   541	625	782	java/io/IOException
  }

  public void parseCookies(URLConnection paramURLConnection)
  {
    Vector localVector;
    StringTokenizer localStringTokenizer;
    Object localObject;
    String str2;
    int i;
    String str3;
    String str4;
    String str5;
    Cookie localCookie2;
    String str1 = paramURLConnection.getHeaderField("Set-Cookie");
    if (str1 != null)
    {
      localVector = new Vector();
      localStringTokenizer = new StringTokenizer(str1, ";,", true);
      localObject = null;
      while (true)
      {
        do
        {
          if (!(localStringTokenizer.hasMoreTokens()))
            break label197;
          str2 = localStringTokenizer.nextToken().trim();
        }
        while (str2.equals(";"));
        if (!(str2.equals(",")))
          break;
        localObject = null;
      }
      i = str2.indexOf(61);
      if (-1 == i)
        if (localObject == null)
        {
          str3 = "";
          str4 = str2;
          str5 = str3;
          if (localObject != null)
            break label211;
        }
    }
    try
    {
      localCookie2 = new Cookie(str3, str4);
    }
    catch (IllegalArgumentException localIllegalArgumentException4)
    {
      label197: label211: String str6;
      String str7;
      try
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              localVector.addElement(localCookie2);
              localObject = localCookie2;
            }
            str3 = str2;
            str4 = null;
            str5 = str3.toLowerCase();
          }
          str3 = str2.substring(0, i);
          str4 = str2.substring(i + 1);
          str5 = str3.toLowerCase();
        }
        localIllegalArgumentException4 = localIllegalArgumentException4;
        if (localVector.size() != 0)
          saveCookies(localVector, paramURLConnection);
        return;
        if (str5.equals("expires"))
        {
          str6 = localStringTokenizer.nextToken();
          label476: str7 = localStringTokenizer.nextToken();
        }
      }
      catch (IllegalArgumentException localIllegalArgumentException2)
      {
        try
        {
          localObject.setExpiryDate(mFormat.parse(str4 + str6 + str7));
        }
        catch (ParseException localParseException)
        {
          Cookie localCookie1;
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                        localObject.setExpiryDate(null);
                      if (!(str5.equals("domain")))
                        break;
                      localObject.setDomain(str4);
                    }
                    if (!(str5.equals("path")))
                      break;
                    localObject.setPath(str4);
                  }
                  if (!(str5.equals("secure")))
                    break;
                  localObject.setSecure(true);
                }
                if (!(str5.equals("comment")))
                  break;
                localObject.setComment(str4);
              }
              if (!(str5.equals("version")))
                break;
              int j = Integer.parseInt(str4);
              localObject.setVersion(j);
            }
            if (!(str5.equals("max-age")))
              break;
            Date localDate = new Date();
            localDate.setTime(localDate.getTime() + 1000 * Integer.parseInt(str4));
            localObject.setExpiryDate(localDate);
          }
          try
          {
            localCookie1 = new Cookie(str3, str4);
          }
          catch (IllegalArgumentException localIllegalArgumentException2)
          {
            try
            {
              while (true)
              {
                localVector.addElement(localCookie1);
                localObject = localCookie1;
              }
              localIllegalArgumentException2 = localIllegalArgumentException2;
            }
            catch (IllegalArgumentException localIllegalArgumentException1)
            {
              break label476:
              localIllegalArgumentException3 = localIllegalArgumentException3;
            }
          }
        }
      }
    }
  }

  protected void saveCookies(Vector paramVector, URLConnection paramURLConnection)
  {
    for (int i = 0; i < paramVector.size(); ++i)
    {
      Cookie localCookie = (Cookie)paramVector.elementAt(i);
      String str = localCookie.getDomain();
      if (str == null)
        str = paramURLConnection.getURL().getHost();
      setCookie(localCookie, str);
    }
  }

  public void setCookie(Cookie paramCookie, String paramString)
  {
    int i;
    int j;
    Cookie localCookie;
    if (paramCookie.getDomain() != null)
      paramString = paramCookie.getDomain();
    String str = paramCookie.getPath();
    if (this.mCookieJar == null)
      this.mCookieJar = new Hashtable();
    Vector localVector1 = (Vector)this.mCookieJar.get(paramString);
    if (localVector1 != null)
    {
      i = 0;
      j = 0;
      if (j < localVector1.size())
      {
        localCookie = (Cookie)localVector1.elementAt(j);
        if (!(localCookie.getName().equalsIgnoreCase(paramCookie.getName())))
          break label157;
        if (!(localCookie.getPath().equals(str)))
          break label131;
        localVector1.setElementAt(paramCookie, j);
        i = 1;
      }
      if (i == 0)
        localVector1.addElement(paramCookie);
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return;
          label131: if (!(str.startsWith(localCookie.getPath())))
            break;
          localVector1.insertElementAt(paramCookie, j);
          i = 1;
        }
        label157: ++j;
      }
      Vector localVector2 = new Vector();
      localVector2.addElement(paramCookie);
      this.mCookieJar.put(paramString, localVector2);
    }
  }

  public void setCookieProcessingEnabled(boolean paramBoolean)
  {
    Hashtable localHashtable;
    if (paramBoolean)
      if (this.mCookieJar == null)
      {
        localHashtable = new Hashtable();
        this.mCookieJar = localHashtable;
      }
    while (true)
    {
      while (true)
      {
        return;
        localHashtable = this.mCookieJar;
      }
      this.mCookieJar = null;
    }
  }

  public void setMonitor(ConnectionMonitor paramConnectionMonitor)
  {
    this.mMonitor = paramConnectionMonitor;
  }

  public void setPassword(String paramString)
  {
    this.mPassword = paramString;
  }

  public void setProxyHost(String paramString)
  {
    this.mProxyHost = paramString;
  }

  public void setProxyPassword(String paramString)
  {
    this.mProxyPassword = paramString;
  }

  public void setProxyPort(int paramInt)
  {
    this.mProxyPort = paramInt;
  }

  public void setProxyUser(String paramString)
  {
    this.mProxyUser = paramString;
  }

  public void setRedirectionProcessingEnabled(boolean paramBoolean)
  {
    this.mRedirectionProcessingEnabled = paramBoolean;
  }

  public void setRequestProperties(Hashtable paramHashtable)
  {
    this.mRequestProperties = paramHashtable;
  }

  public void setUser(String paramString)
  {
    this.mUser = paramString;
  }
}